package com.example.demo.controller;

import com.example.demo.entity.ForeWeatherInfo;
import com.example.demo.entity.Weather;
import com.example.demo.entity.WeatherDaily;
import com.example.demo.entity.WeatherIndex;
import com.example.demo.service.impl.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;

/**
 * @author littlebadfox
 * @date 2022-04-24-18:42
 * @desc
 */
@RestController
@RequestMapping("weather")
public class WeatherController {
    String weatherkey="9f4f6d9ef9bb4c5faa25e174db1c9303";

    @Autowired
    WeatherService weatherService;
    @RequestMapping("/getnow")
    public Weather getNow(@RequestParam("latitude") String latitude,@RequestParam("longitude")String longitude){
        return weatherService.getWeatherNow(latitude,longitude);
    }


    @RequestMapping("/get3D")
    public WeatherDaily get3D(@RequestParam("latitude") String latitude,@RequestParam("longitude")String longitude){
//        System.out.println(latitude+"____"+longitude);
        return  weatherService.getWeather3D(latitude,longitude);
    }

    @RequestMapping("/getnowdate")
    public String getNowDate(){
        return weatherService.getNowDate();
    }

    @RequestMapping("/getweatherindex")
    public List<WeatherIndex> getWeatherIndexInfo(@RequestParam("latitude") String latitude,@RequestParam("longitude")String longitude){
        return weatherService.getWeatherIndexIndo(latitude,longitude);
    }

    @RequestMapping("/getsearchlist")
    public List<Object> getSearchList(@RequestParam("location") String location){
        return weatherService.getSerachList(location);
    }


    @RequestMapping("/get7D")
    public ForeWeatherInfo get7D(@RequestParam("latitude") String latitude, @RequestParam("longitude")String longitude) throws ParseException {
//        System.out.println(latitude+"____"+longitude);
        return  weatherService.getWeather7D(latitude,longitude);
    }

}
